Page({
  data: {
      function_buttons: [
          "https://cdnjson.com/images/2024/02/19/map_guidec371b976f8a8ccfd.png",
          "https://cdnjson.com/images/2024/02/19/school_guide62ff63461eb4a3ff.png",
          "https://cdnjson.com/images/2024/02/19/site_summary577df1180980be2f.png",
          "https://cdnjson.com/images/2024/02/19/friendly_link1f1f62f21021ed5e.png",
          "https://cdnjson.com/images/2024/02/19/site_popularity3b3b4602cf736db0.png"
      ],
      
  },
  onLoad(options) {
      const function_buttons = this.data.function_buttons;
      const preloadImages = function_buttons.map((imgUrl) => {
          return new Promise((resolve, reject) => {
              wx.getImageInfo({
                  src: imgUrl,
                  success: (res) => {
                      resolve(res);
                  },
                  fail: (err) => {
                      reject(err);
                  }
              });
          });
      });
      Promise.all(preloadImages).then(() => {
          this.setData({
              isLoading: false // 图片预加载完成后，隐藏加载提示
          });
          console.log('图片预加载完成');
      }).catch((error) => {
          this.setData({
              isLoading: false // 即使加载出错也隐藏加载提示
          });
          console.error('图片预加载出错：', error);
      });
  },
  match() {
      wx.navigateTo({
          url: '../match/match',
      }).catch((error) => {
          wx.showToast({
              title: '前往比赛页面出错，请稍后再试',
              icon: 'none',
              duration: 2000
          });
          console.error('导航到比赛页面出错：', error);
      });
  },
  score() {
      wx.navigateTo({
          url: '../score/score',
      }).catch((error) => {
          wx.showToast({
              title: '前往成绩页面出错，请稍后再试',
              icon: 'none',
              duration: 2000
          });
          console.error('导航到成绩页面出错：', error);
      });
  },
  site() {
      wx.navigateTo({
          url: '../site/site',
      }).catch((error) => {
          wx.showToast({
              title: '前往场地页面出错，请稍后再试',
              icon: 'none',
              duration: 2000
          });
          console.error('导航到场地页面出错：', error);
      });
  },
  link() {
      wx.navigateTo({
          url: '../link/link',
      }).catch((error) => {
          wx.showToast({
              title: '前往链接页面出错，请稍后再试',
              icon: 'none',
              duration: 2000
          });
          console.error('导航到链接页面出错：', error);
      });
  },
  onShareAppMessage() {
      return {
          title: '定向越野小程序',
          desc: '快来体验定向越野相关功能吧！',
          path: '/pages/yueye/yueye',
          imageUrl: 'https://mp-af6e9e99-abbe-4ad1-871a-a17ef1dc3479.cdn.bspapp.com/南硅谷C.jpg' // 替换为实际的分享图片链接
      };
  }
})